<div class="modal-dialog" role="document" style="width: 1130px;">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                    aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="exampleModalLabel">添加企业</h4>
        </div>

        <div style="padding: 10px 0 10px 10px;height:700px;overflow-y:auto;" >

            <div class="yy-box">
                <form id="companyForm" data-toggle="validator">
                    <input type="hidden" name="id"  value="{$companyInfo.id}">
                    <div class="yy-l">
                        <div class="imgbox">
                            <img class="logo" src="__PUBLIC__/images/avatar.png" alt=""/>
                            <p class="name" title="{$companyInfo.name}">{$companyInfo.name|msubstr=###,0,18,"utf-8",true}</p>
                        </div>
                        <div class="yy-form">
                            <div class="form-group">
                                <label>联系电话</label>
                                <input type="text" class="form-control " name="contact_phone"
                                       value="{$companyInfo.contact_phone}" placeholder="如：012-12345678">
                            </div>
                            <div class="form-group">
                                <label>联系地址</label>
                                <input type="text" class="form-control " name="contact_address"
                                       value="{$companyInfo.contact_address}" placeholder="如：上海市锦建路99号">
                            </div>
                            <button type="submit" class="btn"  style="margin-top: 124px;">保存</button>
                        </div>
                    </div>
                </form>

                <div class="yy-r yy-tab">
                    <div class="tabbox clearfix">
                        <div class="tab-item active">工商信息</div>
                        <div class="tab-item">微信公众号</div>
                        <div class="tab-item">财务信息</div>
                    </div>
                    <div class="tab-pane active">
                        <form id="businessForm" data-toggle="validator">
                            <input type="hidden" name="id"  value="{$companyInfo.id}">
                            <div class="yy-form">
                                <div class="form-group2 clearfix">
                                    <div class="form-group">
                                        <label>企业名称</label>
                                        <input type="text" class="form-control" name="name" value="{$companyInfo.name}">
                                    </div>
                                    <div class="form-group">
                                        <label>注册号/统一社会信用代码</label>
                                        <input type="text" class="form-control" name="registration_capital"
                                               value="{$companyInfo.registration_capital}">
                                    </div>
                                </div>
                                <div class="form-group2 clearfix">
                                    <div class="form-group">
                                        <label>注册时间</label>
                                        <div class='input-group date' id='datetimepicker'>
                                            <input type='text' value="{$companyInfo.registration_time|date='Y-m-d',###}"
                                                   name="registration_time" class="form-control"
                                                   data-date-format="yyyy-mm-dd"/>
                                            <span class="input-group-addon">
					                        <span class="glyphicon glyphicon-calendar"></span></span>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label>注册资本</label>
                                        <input type="text" class="form-control" name="registration_capital"
                                               value="{$companyInfo.registration_capital}">
                                    </div>
                                </div>
                                <div class="form-group2 clearfix">
                                    <div class="form-group clearfix" >
                                        <label>法人代表</label>
                                        <input type="text" class="form-control" name="legal_person"
                                               value="{$companyInfo.legal_person}">
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label">状态：</label>
                                        <select class="form-control" name="type">
                                            <option value="1" <if condition="$companyInfo['type'] eq '1'">selected</if>>正常户</option>
                                            <option value="2" <if condition="$companyInfo['type'] eq '2'">selected</if>>疑似户</option>
                                            <option value="3" <if condition="$companyInfo['type'] eq '3'">selected</if>>空挂户</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label>注册地址</label>
                                    <input type="text" class="form-control" name="registration_address"
                                           value="{$companyInfo.registration_address}">
                                </div>
                                <if condition="$Think.session.default_module == 'Building'">
                                    <div class="form-group">
                                        <label>所属街道:</label>
                                        <select class="form-control" id="org_id" name="org_id" value=''
                                                onchange="showHouseOp(this.value)">
                                            <volist name="orgs" id="item">
                                                <option>
                                                    <if condition="$companyInfo['org_id'] eq $item['id']">
                                                        selected="selected"
                                                    </if>
                                                    value="{$item.id}">{$item.name}</option>
                                            </volist>
                                        </select>
                                    </div>
                                    <div class="form-group">
                                        <label>所属楼宇:</label>
                                        <select name="house_id" class="form-control" id="house_id">
                                        </select>
                                    </div>
                                    <div class="form-group">
                                        <label>所属行业:</label>
                                        <select name="industry_id" class="form-control" id="industry_id">
                                            <option value="{$item.id}">--请选择--</option>
                                            <volist name="industrys" id="item">
                                                <option
                                                <if condition="$companyInfo['industry_id'] eq $item['id']">
                                                    selected="selected"
                                                </if>
                                                value="{$item.id}">{$item.name}</option>
                                            </volist>
                                        </select>
                                    </div>
                                    <else/>
                                    <!--<div class="form-group">
                                        <label>所属空间:</label>
                                        <select name="space_id" class="form-control" id="space_id">
                                            <option value="{$item.id}">&#45;&#45;请选择&#45;&#45;</option>
                                            <volist name="spaces" id="item">
                                                <option value="{$item.id}" <if condition="$companyInfo['space_id'] eq $item['id']">selected="'selected"</if>
                                                    >{$item.name}
                                                </option>
                                            </volist>
                                        </select>
                                    </div>-->

                                </if>
                                <div class="form-group">
                                    <label>营业执照<span class="tag-state">未上传</span></label>
                                    <input type="file" id="">
                                </div>
                                <div class="form-group">
                                    <label>经营范围</label>
                                    <textarea rows="4" class="form-control" name="scope"
                                              cols="200">{$companyInfo.scope}</textarea>
                                </div>
                            </div>
                            <button type="submit" class="btn" id="saveCompanyBtn">保存</button>
                        </form>
                    </div>
                    <div class="tab-pane">
                        <form>
                            <input type="hidden" name="id"  value="{$companyInfo.id}">
                            <div class="yy-form">
                                <div class="form-group">
                                    <label>微信公众号名称<span class="required">*</span></label>
                                    <input type="text" class="form-control" name="" value="" placeholder="">
                                </div>
                                <div class="form-group">
                                    <label>公众号appId<span class="required">*</span></label>
                                    <input type="text" class="form-control" name="" value="" placeholder="18位数字和字母组合">
                                </div>
                                <div class="form-group">
                                    <label>公众号appSecret<span class="required">*</span></label>
                                    <input type="text" class="form-control" name="" value="" placeholder="32位数字和字母组合">
                                </div>
                                <div class="form-group">
                                    <label>二维码logo<span class="required">*</span></label>
                                    <input type="file" id="">
                                </div>
                                <div class="remark">备注：<br/>1.仅支持服务号类型微信公众号 <br/>2.请确保模板消息功能已经开通，并确保所在行业包括《IT科技-互联网|电子商务》<br/>3.完成设置后会为服务号自动添加模板消息，请勿删除<br/>4.appId设置后不能更改，如需更改请联系客服<br/>
                                </div>
                            </div>
                            <if condition="$actionName neq info">
                                <button type="submit" class="btn">完成并设置</button>
                            </if>
                        </form>
                    </div>
                    <div class="tab-pane">
                        <form>
                            <input type="hidden" name="id"  value="{$companyInfo.id}">
                            <div class="finance-title">默认含税收款账户</div>
                            <div class="yy-form">
                                <div class="form-group">
                                    <label>账户名</label>
                                    <input type="text" class="form-control" name="" value=""
                                           placeholder="如：上海优空信息科技有限公司">
                                </div>
                                <div class="form-group">
                                    <label>账号</label>
                                    <input type="text" class="form-control" name="" value=""
                                           placeholder="如：121917782111111">
                                </div>
                                <div class="form-group">
                                    <label>开户行</label>
                                    <input type="text" class="form-control" name="" value=""
                                           placeholder="如：招商银行股份有限公司泰兴支行">
                                </div>
                            </div>
                            <div class="finance-title">默认含税收款账户</div>
                            <div class="yy-form">
                                <div class="form-group">
                                    <label>账户名</label>
                                    <input type="text" class="form-control" name="" value=""
                                           placeholder="如：上海优空信息科技有限公司">
                                </div>
                                <div class="form-group">
                                    <label>账号</label>
                                    <input type="text" class="form-control" name="" value=""
                                           placeholder="如：121917782111111">
                                </div>
                                <div class="form-group">
                                    <label>开户行</label>
                                    <input type="text" class="form-control" name="" value=""
                                           placeholder="如：招商银行股份有限公司泰兴支行">
                                </div>
                            </div>
                            <if condition="$actionName neq info">
                                <button type="submit" class="btn">保存</button>
                            </if>
                        </form>
                    </div>
                </div>
            </div>


            <!--<div class="form-group">
                <label for="message-text" class="control-label">广告位:</label>
                <div class="">
                    <select name="prid" class="input-xlarge">
                        <option>1</option>
                        <option>2</option>
                        <option>3</option>
                        <option>4</option>
                    </select>
                </div>

            </div>-->

            <!-- <div class="form-group">
                 <label for="message-text" class="control-label">状&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;态:</label>
                 <input type="checkbox" name="status" value="1" />
            </div>-->
        </div>
    </div>
</div>

<script>
    var company_id = $('#companyId').val;
    var houseId = $('#houseId').val();
    var org_id = $('org_id').val() > 1 ? $('org_id').val() : 0;
    $(function () {
        //$('#businessForm').validator();
        showHouseOp(org_id);
    })
    $('#datetimepicker').datetimepicker({
        format: 'yyyy-mm-dd',
        language: 'ch',
        pickDate: true,
        pickTime: false,
        autoclose: true,
        minView: 2
    });
    $("#saveCompanyBtn").click(function () {
        alert(11111);
//        var validator = $("#companyForm").data("bs.validator");
//        validator.validate();
//        if (!validator.hasErrors()) {
        $.ajax({
            url: "{:U('Admin/Company/doAddCompany')}",
            type: "post",
            dataType: "json",
            data: $("#businessForm").serialize(),
            success: function (data) {
                if (data.status) {
                    $("#commonModal").modal('toggle');
                    common.alert("提示", "企业信息保存成功!", function () {
                        common.reload();
                    });
                }
            },
            error:function (data) {
                alert(data.status);
            }
        })
//        }
    })
    function showHouseOp(org_id) {
        $.ajax({
            url: "{:U('Api/House/getAllHouse')}",
            type: "post",
            data: {
                'org_id': org_id,
            },
            success: function (data) {
                $("#house_id").empty();
                var html = '<option value="">--请选择--</option>';
                if (data.data.length > 0) {
                    $.each(data.data, function (index, item) {
                        var strSelect = '';
                        if (item.id == houseId) {
                            strSelect = ' selected';
                        }
                        html += '<option value="' + item.id + '"' + strSelect + '>' + item.name + '</option>';
                    });

                }
                $("#house_id").html(html);
            }
        })
    }
    //tab切换
    $('.tabbox .tab-item').click(function () {
        $(this).addClass('active').siblings().removeClass('active');
        $('.tab-pane').eq($(this).index()).addClass('active').siblings().removeClass('active');
    })
</script>